// rollup.config.mjs
// ---cut-start---
/** @type {import('rollup').RollupOptions} */
// ---cut-end---
import typescript from 'rollup-plugin-typescript2';
// 生成声明文件
import { dts } from "rollup-plugin-dts";
import terser from '@rollup/plugin-terser'


export default [{
        input: 'src/main.ts',
        output: {
            file: './lib/bundle.umd.js',
            name: 'xyUtils',
            // 浏览器默认 将xyUtils挂载到window上
            format: 'umd'
        },
        plugins: [
            typescript(),
            terser()
        ],
    },
    {
        input: 'src/main.ts',
        output: {
            file: './lib/bundle.esm.js',
            name: 'xyUtils',
            // ES6模块
            format: 'esm',
        },
        plugins: [
            typescript(),
            terser({
                compress: {
                    drop_console: true,
                    drop_debugger: true,
                },
            })
        ],

    },
    {
        input: "src/main.ts",
        output: [{ file: "./lib/index.d.ts", format: "es" }],
        plugins: [dts()],
    },
    {
        input: 'src/main.ts',
        output: {
            file: './lib/bundle.cjs.js',
            name: 'utils',
            // CommonJS模块
            format: 'cjs'
        },
        plugins: [
            typescript(),
        ],
    }
];